<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/1/19
 * Time: 21:19
 */

defined('BASEPATH') OR exit('No direct script access allowed');

class Main_mod extends CI_Model{
    public function __construct()
    {
        parent::__construct();

    }

/*    public function article(){
        $query = $this->db->get('article');
        //如果是数组就用result_array() 如果不是就用result()
        return $query->result_array();
    }*/

    function getArticle($where='',$start=0,$limit=0,$order_by="aid DESC"){
        // 从哪张表获取数据
        $this->db->from('article');
        if($where){
            $this->db->where($where);
        }
        if($order_by){
            $this->db->order_by($order_by);
        }
        if($limit>0){
            $this->db->limit($limit,$start);
        }
        $res = $this->db->get();
        return $res->result_array();
    }

    function getCount($where){
        if($where){
            $this->db->where($where);
        }

        return $this->db->count_all_results('article');

    }

}

?>